Component({
  externalClasses: ['class'],

  properties: {
    info: String,
    type: String,
    size: {
      type:Number,
      value: 23
    },
    fontsize:{
      type:Number,
      value: 14
    },
    color: {
      type:String,
      value:"inherit"
    },
    showtype:{
      type:String,
      value:"default"
    },
    duration:{
      type:Number,
      value:1500
    }
  },

  methods: {
    onTap() {
      let {info, showtype, duration} = this.data;
      if(info){
        if(showtype=='toast')
          wx.showToast({
            title: info,icon:"none", duration
          })
        else if(showtype=='modal')
          wx.showModal({
            content: info, showCancel:false,duration
          })
        else
          this.showInfo()
      }
    },
    showInfo(){
      if (this.timeid)
        clearTimeout(this.timeid);
      this.setData({showInfo:1});
      this.timeid = setTimeout(() => {
        this.hideInfo();
      },this.data.duration);
    },
    hideInfo(){
      this.setData({showInfo:0});
      this.timeid = null;
    }
  }
});